package com.loongtech.bi.support;

import java.util.List;

public class Helper {
	
	/**
	 * 格式化将选中的数据转换为逗号分隔的字符串格式，方便执行sql
	 * @param list
	 * @return
	 */
	public static String toSqlInStr(List<String> list, boolean includeAll) {
		if(list == null || list.isEmpty()) {
			return "";
		}
		StringBuffer sb = new StringBuffer();
		for(String l : list) {
			// 是否排除0
			if(null == l || (!includeAll && "0".equals(l))) continue;

			sb.append(l);
			sb.append(",");
		}
		if(sb.length()>0){
			sb = sb.deleteCharAt(sb.lastIndexOf(","));
		}
		return sb.toString();
	}
	
	/**
	 * 当list为空或大小为0或存的值为null，返回true
	 * @param list
	 * @return
	 */
	public static boolean isEmptyValue(List<?> list) {
		return list == null || list.size() <= 0 || list.get(0) == null;
	}
}
